import axiosInstance from "@/utils/axiosInstance";
const foodInfo = {
    /**
     * 分页获取菜品列表
     * @param {pageIndex,food_name,category_name} param0 
     * @returns  {Promise<AxiosResponse<any>
     */
    getListByPage({ pageIndex, food_name, category_name }) {
        return axiosInstance.get(`/foodInfo/getListByPage`, {
            params: {
                pageIndex, food_name, category_name
            }
        })
    },
    /**
     * 设置某个菜品的权重值
     * @param {id,weight} param0 
     * @returns {Promise<AxiosResponse<any>
     */
    setFoodInfoWeight({ id, weight }) {

        return axiosInstance.get(`/foodInfo/setFoodInfoWeight`, {
            params: {
                id, weight
            }
        })
    },
    /**
     * 新增菜品的内容
     * @param {Number} id
     * @param {String} food_name
     * @param {String} price
     * @param {String} food_desc
     * @param {Image} food_img
     * @param {Number} weight
     * @returns {Promise<AxiosResponse<any>
     */
    add({ food_name, price, cid, food_desc, food_img, weight }) {
        return axiosInstance.post(`/foodInfo/add`, {
            food_name, price, cid, food_desc, food_img, weight
        });
    },
    /**
     * 根据id删除菜品信息
     * @param {number} id 
     * @returns  {Promise<AxiosResponse<any>
     */
    deleteById(id) {
        return axiosInstance.get(`/foodInfo/deleteById`, {
            params: {
                id
            }
        })
    },
    /**
     * 根据id查询菜品的信息
     * @param {number} id 
     * @returns  {Promise<AxiosResponse<any>
     */
    findById(id) {
        return axiosInstance.get(`/foodInfo/findById`, {
            params: {
                id
            }
        })
    },
    /**
     * 修改数据
     * @param {Number} id
     * @param {String} food_name
     * @param {String} price
     * @param {String} food_desc
     * @param {Image} food_img
     * @param {Number} weight
     * @returns  {Promise<AxiosResponse<any>
     */
    update({id,food_name,price,cid,food_desc,food_img,weight}){
        return axiosInstance.post(`/foodInfo/update`,{
            id,food_name,price,cid,food_desc,food_img,weight
        })
    }
}

export default foodInfo;